package com.sky.controller.admin;


import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/setmeal")
@Slf4j
public class SetMeaController {
    @Autowired
    private SetmealService setmealService;

    @PostMapping
    public Result addNewSetmeal(@RequestBody SetmealDTO setmealDTO){

        setmealService.addSetmeal(setmealDTO);

        return Result.success();

    }
    @GetMapping("/page")
    public Result<PageResult> getSetmealPage(SetmealPageQueryDTO setmealPageQueryDTO){

        PageResult pageResult=setmealService.pageQuery(setmealPageQueryDTO);
        return Result.success(pageResult);
    }

    @DeleteMapping
    public Result deleteSetmeal(@RequestParam List<Long> ids){
        setmealService.delete(ids);
        return Result.success();

    }
}
